import json
import os
import csv

from utils.path_manager import path_manager


class TestData():

    @staticmethod
    def get_json_data(filename):

        filename = (os.path.join(path_manager.data_dir, filename))

        with open(filename, 'r', encoding="utf-8") as f:
            data = json.load(f)

            data_arr = data.get("data")
            data_tuple_arr = []
            for d in data_arr:
                data_arr_temp = []
                for value in d.values():
                    data_arr_temp.append(value)
                data_tuple_arr.append(tuple(data_arr_temp))

            return data_tuple_arr

    @staticmethod
    def get_csv_data(filename):

        filename = (os.path.join(path_manager.data_dir, filename))
        data_tuple_arr = []

        with open(filename, 'r') as file:
            csv_file = csv.reader(file)

            for line in csv_file:
                data_tuple_arr.append(tuple(line))
        return data_tuple_arr
